#include <bits/stdc++.h>
using namespace std;
int g[6][6];
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int n, m;
    int row = 50, col = 50;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) {
        char c;
        cin >> c;
        g[i][j] = (c == 'R');
        if (g[i][j]) {
          row = min(row, i);
          col = min(col, j);
        }
      }
    cout << (g[row][col] ? "YES\n" : "NO\n");
  }
}
